home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Misc / GMS / GMSDev / Source / C / Blitter / Rosette.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-12-16  |  2.0 KB  |  78 lines

  1. /* Name:  Rosette (Converted from Amiga Graphics Inside and Out)
  2. ** SAS/C: sc Rosette.c opt math=standard INCDIR=INCLUDES:
  3. */
  4.  
  5. #include <proto/dpkernel.h>
  6. #include <math.h>
  7.  
  8. BYTE *ProgName      = "Rosette";
  9. BYTE *ProgAuthor    = "Paul Manias";
  10. BYTE *ProgDate      = "8 October 1997";
  11. BYTE *ProgCopyright = "DreamWorld Productions (c) 1996-1997.  Freely distributable.";
  12. BYTE *ProgShort     = "Draws various rosette pattenrs.";
  13.  
  14. struct GScreen *screen;
  15. struct JoyData *joydata;
  16.  
  17. void Rosette(void);
  18.  
  19. #define AMTCOLOURS 32
  20.  
  21. LONG palette[AMTCOLOURS+2] = {
  22.   PALETTE,32,
  23.   0x000000L,0x101010L,0x171717L,0x202020L,0x272727L,0x303030L,0x373737L,0x404040L,
  24.   0x474747L,0x505050L,0x575757L,0x606060L,0x676767L,0x707070L,0x777777L,0x808080L,
  25.   0x878787L,0x909090L,0x979797L,0xa0a0a0L,0xa7a7a7L,0xb0b0b0L,0xb7b7b7L,0xc0c0c0L,
  26.   0xc7c7c7L,0xd0d0d0L,0xd7d7d7L,0xe0e0e0L,0xe0e0e0L,0xf0f0f0L,0xf7f7f7L,0xffffffL
  27. };
  28.  
  29. /***********************************************************************************/
  30.  
  31. void main(void)
  32. {
  33.   if (screen = InitTags(NULL,
  34.      TAGS_SCREEN,    NULL,
  35.        GSA_BitmapTags, NULL,
  36.        BMA_AmtColours, AMTCOLOURS,
  37.        TAGEND,         NULL,
  38.      GSA_Palette,    palette,
  39.      TAGEND)) {
  40.  
  41.      Display(screen);
  42.  
  43.      if (joydata = Init(Get(ID_JOYDATA),NULL)) {
  44.  
  45.         Rosette();
  46.  
  47.      Free(joydata);
  48.      }
  49.   Free(screen);
  50.   }
  51. }
  52.  
  53. /***********************************************************************************/
  54.  
  55. void Rosette(void)
  56. {
  57.   WORD offsetx = (screen->Width/2);
  58.   WORD offsety = (screen->Height/2);
  59.   double t, angle, x, y;
  60.   double inside  = 3.0, radius = 100.0,
  61.          outside = 3.0, f      = 0.5,
  62.          edges   = 10;
  63.  
  64.   for (t = -inside/10; t < (outside/10); t += 0.1) {
  65.     Query(joydata);
  66.     if (joydata->Buttons & JD_LMB) {
  67.        return;
  68.     }
  69.  
  70.     for (angle = 0; angle < (2*PI); angle += 0.01) {
  71.       x = radius * cos(angle) + t * radius * cos(angle * edges);
  72.       y = radius * sin(angle) + t * radius * sin(angle * edges);
  73.       DrawPixel(screen->Bitmap, (WORD)(x+offsetx), (WORD)(y*f+offsety), FastRandom(AMTCOLOURS));
  74.     }
  75.   }
  76. }
  77.  
  78.